var table ;
layui.use(['layer', 'table', 'laydate', 'jquery'], function(){
    table = layui.table;
    var $=layui.$;//使用内置jquery
    var layer = layui.layer; //弹层

    let url="/logisticsSign/orderInformation"
    var id=-1;
    $.ajax({
        type: 'post',
        url: url,
        data: null,
        async:false,
        dataType: 'json',
        success: function (response) {
            if (response.code == 1){
                console.info(response.data);
                $("#clientId").val(response.data.clientId)
                id=$("#clientId").val();
                console.info("id="+id);
            }else {
                console.info(response.msg);
            }
        }
    })


    table.render({
        elem: '#test'
        ,id:'dataListrece'
        ,where:{orderState:"已签收"}
        ,url:'/logisticsOrder/select2?clientId='+id
       // ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
        ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
            title: '提示'
            ,layEvent: 'LAYTABLE_TIPS'
            ,icon: 'layui-icon-tips'
        }]
        ,title: '用户数据表'
        ,cols: [[
            {type: 'checkbox', fixed: 'left'}
            ,{field:'orderId', title:'订单号', width:120, fixed: 'left', unresize: true, sort: true}
            ,{field:'orderNumber', title:'订单编号', width:120,edit: 'text'}
            ,{field:'clientName', title:'姓名', width:120, edit: 'text', unresize: true, sort: true}
            ,{field:'cargoType', title:'货物类型', width:120, edit: 'text'}
            ,{field:'orderDeparture', title:'出发地', width:150, edit: 'text'}
            ,{field:'orderBourn', title:'收件地', width:150, edit: 'text'}
            ,{field:'orderPrice', title:'订单金额',width:100,edit: 'text'}
            ,{field:'orderState', title:'订单状态', width:120,edit: 'text'}
            ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:200}
        ]]
        ,page: true
    });

    //监听行工具事件
    table.on('tool(test)', function(obj){
        var data = obj.data;
        //console.log(obj)
        if(obj.event === 'detail'){
            layer.open({
                type: 2,
                area: ['600px', '600px'],
                fixed: false, //不固定
                maxmin: true,
                content: '/pages/signfor/html/signIndex.html?id='+data.orderId,
            });
        }
    });



    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    };


    $('#queery').on("click", function () {
        var date_ = {
            orderState: "未签收",
        };
        table.reload('dataListrece', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            , where: date_  //需要传到后台的参数
        });
    })


});